package site.eblog.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import site.eblog.dao.ArticleMapper;
import site.eblog.entity.Article;
import site.eblog.entity.User;

@Transactional
@Service
public class ArticleServiceImpl implements ArticleService {

	@Autowired ArticleMapper articleMapper;
	
	@Override
	public int getArticlesByName(String userName) {
		int res = articleMapper.getArticlesByName(userName);
		return res;
	}
	
	@Override
	public int getYCArticlesByName(String userName) {
		int res = articleMapper.getYCArticlesByName(userName);
		return res;
	}

	@Override
	public List<Article> getArticleByAuthor(Article article) {
		List<Article> articles = new ArrayList<>();
		articles = articleMapper.getArticleByAuthor(article);
		return articles;
	}

	@Override
	public int addArticle(Article article) {
		int res = articleMapper.addArticle(article);
		return res;
	}

	@Override
	public Article getArticleById(String id) {
		Article article = new Article();
		article = articleMapper.getArticleById(id);
		return article;
	}

	@Override
	public int upDateArticle(Article article) {
		int res = articleMapper.upDateArticle(article);
		return res;
	}

	@Override
	public int delArticle(int id) {
		int res = articleMapper.delArticle(id);
		return res;
	}

	@Override
	public int batchDelArticle(String[] ArrayList) {
		int res = articleMapper.batchDelArticle(ArrayList);
		return res;
	}

	@Override
	public List<Article> articleSelect(Map<String, String> map) {
		List<Article> articles = articleMapper.articleSelect(map);
		return articles;
	}

	@Override
	public List<Article> readTop(String author) {
		List<Article> articles   = new ArrayList<Article>();
		articles = articleMapper.readTop(author);
		return articles;
	}

	@Override
	public List<Article> tuijianTop(String author) {
		List<Article> articles   = new ArrayList<Article>();
		articles = articleMapper.tuijianTop(author);
		return articles;
	}

	@Override
	public List<Article> searchArticleByTitle(String title) {
		List<Article> articles = articleMapper.searchArticleByTitle(title);
		return articles;
	}

	@Override
	public int upDateReadNById(Map<String, Object> map) {
		int res = articleMapper.upDateReadNById(map);
		return res;
	}

	@Override
	public int upDateRecommendNById(Map<String, Object> map) {
		int res = articleMapper.upDateRecommendNById(map);
		return res;
	}
}
